Skip to content

refactor(export): drop send_rgba and the state that existed only for it (Linux) - #580

Merged
EtienneLescot merged 1 commit into
mainfrom
chore/drop-send-rgba
Sep 3, 2026
Merged

refactor(export): drop send_rgba and the state that existed only for it (Linux)#580
EtienneLescot merged 1 commit into
mainfrom
chore/drop-send-rgba

Conversation

@EtienneLescot

@EtienneLescot EtienneLescot commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Net −61 lines. send_rgba lost its production caller when the YUV conversion moved to the GPU (#555): the export feeds the encoder through copy_into from a GPU-strided pool frame.

It was not quite dead, though, which is why this is a refactor and not a deletion. The tests added with #575 used it to push frames in — so they were verifying the encoder configuration through a path production no longer takes. They now feed through copy_into and a YuvLayout buffer, i.e. exactly what the export does.

That migration needed a content change, and it is the interesting part. My first replacement pattern produced keyframes at 0/17/34 instead of 0/20/40: a contrasty motif wakes openh264 scene-change detection, and the test would then have been measuring that rather than gop_size. It now writes a coarse, low-amplitude gradient sliding one step per frame — enough residual for the encoder to work on, not enough discontinuity to trigger a cut.

With send_rgba gone the compiler found the rest:

  • VideoEncoder::sw — a 3.1 MB AVFrame allocated per encoder, unwritten since the pool took over
  • sws: *mut SwsContext beside it
  • SWS_POINT
  • alloc_sw_frame

VideoEncoder::open no longer has a fallible step after avcodec_open2, so its error branch went too.

Verified: 215 tests pass, and both export paths run end to end — hardware and software, 3600 frames each.

Summary by CodeRabbit

  • Performance

    • Video encoding now receives GPU-converted YUV420P frames, reducing redundant color conversion during encoding.
  • Compatibility

    • The encoder no longer accepts RGBA frame data directly; input frames must use the YUV420P format.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 90adb109-72a6-49ae-9ce1-7260767e0f33

📥 Commits

Reviewing files that changed from the base of the PR and between 855e0fa and 530338b.

📒 Files selected for processing (1)
  • crates/compositor/src/pipeline_linux.rs

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

VideoEncoder no longer converts RGBA input to YUV420P. It now receives YUV420P frames, while the encode test uses the production frame-copy path with pooled padded frames.

Changes

YUV420P encoder input

Layer / File(s) Summary
Encoder YUV420P contract
crates/compositor/src/pipeline_linux.rs
VideoEncoder removes libswscale state, RGBA submission, software-frame allocation, and related cleanup. try_open now returns an encoder with only its codec context and dimensions.
Production-path encode test
crates/compositor/src/pipeline_linux.rs
The test creates padded YUV420P frames, writes luma and chroma planes, and submits frames through copy_into and avcodec_send_frame.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 427ed

Linux export now accepts GPU-produced YUV420P frames directly and removes the unused RGBA conversion path. The updated test exercises the production-style frame copy path, with no current merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description clearly explains the refactor, test migration, content-pattern change, cleanup, and verification results. However, it omits the required template sections for Related issue, Type of ch… Reformat the description with all required template sections. Identify the related issue references, select Refactor / maintenance and the applicable release and Linux impact options, state whether screenshots or video are not applicable, a…
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main Linux export refactor: removing send_rgba and the state used only by that method.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description clearly explains the refactor, test migration, content-pattern change, cleanup, and verification results. However, it omits the required template sections for Related issue, Type of change, Release impact, Desktop impact, Screenshots / video, and Testing headings or checkboxes.

Resolution

Reformat the description with all required template sections. Identify the related issue references, select Refactor / maintenance and the applicable release and Linux impact options, state whether screenshots or video are not applicable, and place the test commands and end-to-end verification under Testing.

✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/drop-send-rgba

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…it (Linux)

Net −61 lines. `send_rgba` had no production caller once the YUV conversion moved
to the GPU: the export feeds the encoder through `copy_into` from a
GPU-strided pool frame, and nothing else called it.

It was not quite dead, which is why this is a refactor rather than a deletion.
The tests added with the keyframe fix used it to push frames in — so they were
verifying the encoder's configuration through a path production no longer takes.
They now feed through `copy_into` and a `YuvLayout` buffer, which is what the
export actually does, so they exercise the real thing rather than a parallel one.

That migration needed a content change, and the reason is worth recording: the
first pattern I used gave keyframes at 0/17/34 instead of 0/20/40 — a contrasty
motif wakes openh264's scene-change detection, and the test would then have been
measuring that rather than `gop_size`. It now writes a coarse, low-amplitude
gradient sliding one step per frame: enough residual to make the encoder work,
not enough discontinuity to trigger a scene cut.

With `send_rgba` gone, the compiler found the rest: `VideoEncoder::sw` (a 3.1 MB
AVFrame allocated per encoder and never written since the pool took over), the
`sws: *mut SwsContext` beside it, `SWS_POINT`, and `alloc_sw_frame`. All removed,
and `VideoEncoder::open` no longer has a fallible step after `avcodec_open2`, so
its error branch went with them.

215 tests pass; both export paths verified end to end, 3600 frames each.
@EtienneLescot
EtienneLescot merged commit d63d552 into main Sep 3, 2026
18 checks passed
@EtienneLescot
EtienneLescot deleted the chore/drop-send-rgba branch September 3, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant